<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">

	<title>Class WXBizMsgCrypt</title>

	<link rel="stylesheet" href="resources/style.css?e99947befd7bf673c6b43ff75e9e0f170c88a60e">

</head>

<body>
<div id="left">
	<div id="menu">
		<a href="index.html" title="Overview"><span>Overview</span></a>


		<div id="groups">
				<h3>Packages</h3>
			<ul>
				<li>
					<a href="package-None.html">
						None					</a>

						</li>
				<li>
					<a href="package-WxRobot.html">
						WxRobot<span></span>
					</a>

						<ul>
				<li>
					<a href="package-WxRobot.Admin.html">
						Admin					</a>

						</li>
				<li>
					<a href="package-WxRobot.Cmd.html">
						Cmd					</a>

						</li>
				<li>
					<a href="package-WxRobot.CoreFunctions.html">
						CoreFunctions					</a>

						</li>
				<li>
					<a href="package-WxRobot.Exends.html">
						Exends					</a>

						</li>
				<li>
					<a href="package-WxRobot.Install.html">
						Install					</a>

						</li>
				<li>
					<a href="package-WxRobot.Table.html">
						Table					</a>

						</li>
				<li>
					<a href="package-WxRobot.Uninstall.html">
						Uninstall					</a>

						</li>
				<li>
					<a href="package-WxRobot.WxSDK.html">
						WxSDK					</a>

						</li>
							</ul></li>
			</ul>
		</div>

		<hr>


		<div id="elements">
			<h3>Classes</h3>
			<ul>
				<li><a href="class-ErrorCode.html">ErrorCode</a></li>
				<li><a href="class-PKCS7Encoder.html">PKCS7Encoder</a></li>
				<li><a href="class-Prpcrypt.html">Prpcrypt</a></li>
				<li><a href="class-SHA1.html">SHA1</a></li>
				<li><a href="class-Weixin_BaseCore.html">Weixin_BaseCore</a></li>
				<li><a href="class-WeiXin_SDK.html">WeiXin_SDK</a></li>
				<li><a href="class-Weixin_Template.html">Weixin_Template</a></li>
				<li class="active"><a href="class-WXBizMsgCrypt.html">WXBizMsgCrypt</a></li>
				<li><a href="class-XMLParse.html">XMLParse</a></li>
			</ul>





		</div>
	</div>
</div>

<div id="splitter"></div>

<div id="right">
<div id="rightInner">
	<form id="search">
		<input type="hidden" name="cx" value="">
		<input type="hidden" name="ie" value="UTF-8">
		<input type="text" name="q" class="text" placeholder="Search">
	</form>

	<div id="navigation">
		<ul>
			<li>
				<a href="index.html" title="Overview"><span>Overview</span></a>
			</li>
			<li>
<span>Package</span>			</li>
			<li class="active">
<span>Class</span>			</li>
		</ul>
		<ul>
		</ul>
		<ul>
		</ul>
	</div>

<div id="content" class="class">
	<h1>Class WXBizMsgCrypt</h1>


	<div class="description">
	<p>1.第三方回复加密消息给公众平台；
2.第三方收到公众平台发送的消息，验证消息的安全性，并对消息进行解密。</p>
	</div>









	<div class="info">
		
		
		
		

				<b>Copyright:</b>
				Copyright (c) 1998-2014 Tencent Inc.<br>
			<b>Located at</b> <a href="source-class-WXBizMsgCrypt.html#15-149" title="Go to source code">weixin-sdk-api/weixin_crypt/wxBizMsgCrypt.php</a>
		<br>
	</div>



	<table class="summary methods" id="methods">
	<caption>Methods summary</caption>
	<tr data-order="WXBizMsgCrypt" id="_WXBizMsgCrypt">

		<td class="attributes"><code>
			 public 

			
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_WXBizMsgCrypt">#</a>
		<code><a href="source-class-WXBizMsgCrypt.html#25-36" title="Go to source code">WXBizMsgCrypt</a>( <span> <var>$token</var></span>, <span> <var>$encodingAesKey</var></span>, <span> <var>$appId</var></span> )</code>

		<div class="description short">
			<p>构造函数</p>
		</div>

		<div class="description detailed hidden">
			<p>构造函数</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$token</var></dt>
					<dd>公众平台上，开发者设置的token</dd>
					<dt><var>$encodingAesKey</var></dt>
					<dd>公众平台上，开发者设置的EncodingAESKey</dd>
					<dt><var>$appId</var></dt>
					<dd>公众平台的appId</dd>
				</dl></div>





		</div>
		</div></td>
	</tr>
	<tr data-order="encryptMsg" id="_encryptMsg">

		<td class="attributes"><code>
			 public 

			integer
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_encryptMsg">#</a>
		<code><a href="source-class-WXBizMsgCrypt.html#38-83" title="Go to source code">encryptMsg</a>( <span> <var>$replyMsg</var></span>, <span> <var>$timeStamp</var></span>, <span> <var>$nonce</var></span>, <span>&amp;$encryptMsg <var>&amp; $encryptMsg</var></span> )</code>

		<div class="description short">
			<p>将公众平台回复用户的消息加密打包.</p>

<ol>
   <li>对要发送的消息进行AES-CBC加密</li>
   <li>生成安全签名</li>
   <li>将消息密文和安全签名打包成xml格式</li>
</ol>
		</div>

		<div class="description detailed hidden">
			<p>将公众平台回复用户的消息加密打包.</p>

<ol> <li>对要发送的消息进行AES-CBC加密</li> <li>生成安全签名</li> <li>将消息密文和安全签名打包成xml格式</li>
</ol>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$replyMsg</var></dt>
					<dd>公众平台待回复用户的消息，xml格式的字符串</dd>
					<dt><var>$timeStamp</var></dt>
					<dd>时间戳，可以自己生成，也可以用URL参数的timestamp</dd>
					<dt><var>$nonce</var></dt>
					<dd>随机串，可以自己生成，也可以用URL参数的nonce</dd>
					<dt><var>$encryptMsg</var></dt>
					<dd><p>加密后的可以直接回复用户的密文，包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串,
                     当return返回0时有效</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					integer<br>成功0，失败返回对应的错误码
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="decryptMsg" id="_decryptMsg">

		<td class="attributes"><code>
			 public 

			integer
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_decryptMsg">#</a>
		<code><a href="source-class-WXBizMsgCrypt.html#86-147" title="Go to source code">decryptMsg</a>( <span> <var>$msgSignature</var></span>, <span> <var>$timestamp</var></span>, <span> <var>$nonce</var></span>, <span> <var>$postData</var></span>, <span>&amp;$msg <var>&amp; $msg</var></span> )</code>

		<div class="description short">
			<p>检验消息的真实性，并且获取解密后的明文.</p>

<ol>
   <li>利用收到的密文生成安全签名，进行签名验证</li>
   <li>若验证通过，则提取xml中的加密消息</li>
   <li>对消息进行解密</li>
</ol>
		</div>

		<div class="description detailed hidden">
			<p>检验消息的真实性，并且获取解密后的明文.</p>

<ol> <li>利用收到的密文生成安全签名，进行签名验证</li> <li>若验证通过，则提取xml中的加密消息</li> <li>对消息进行解密</li>
</ol>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$msgSignature</var></dt>
					<dd>签名串，对应URL参数的msg_signature</dd>
					<dt><var>$timestamp</var></dt>
					<dd>时间戳 对应URL参数的timestamp</dd>
					<dt><var>$nonce</var></dt>
					<dd>随机串，对应URL参数的nonce</dd>
					<dt><var>$postData</var></dt>
					<dd>密文，对应POST请求的数据</dd>
					<dt><var>$msg</var></dt>
					<dd>解密后的原文，当return返回0时有效</dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					integer<br>成功0，失败返回对应的错误码
				</div>




		</div>
		</div></td>
	</tr>
	</table>


















</div>

	<div id="footer">
		 API documentation generated by <a href="http://apigen.org">ApiGen</a>
	</div>
</div>
</div>
<script src="resources/combined.js"></script>
<script src="elementlist.js"></script>
</body>
</html>
